﻿<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="http://schemas.panthernet.ru/graphx/">

    <LinearGradientBrush x:Key="NormalBrush" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#FFFFFFFF" Offset="0"/>
        <GradientStop Color="#FFA4ADBB" Offset="0.521"/>
        <GradientStop Color="#FFD7E0EA" Offset="0.194"/>
        <GradientStop Color="#FFBAC1CF" Offset="0.811"/>
        <GradientStop Color="#FFBCC5D5" Offset="0.507"/>
        <GradientStop Color="#FFE3E4E6" Offset="1"/>
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="NormalBorderBrush" EndPoint="0.5,0" StartPoint="0.5,1">
        <GradientStop Color="#FF8B8B8B"/>
        <GradientStop Color="#FFADADAD" Offset="1"/>
    </LinearGradientBrush>
    <SolidColorBrush x:Key="NormalHighlightBrush" Color="#FFFFFFFF"/>
    <LinearGradientBrush x:Key="MouseOverBrush" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#FFFFFFFF" Offset="0" />
        <GradientStop Color="#FFFEF3B5" Offset="0.318" />
        <GradientStop Color="#FFFFEB70" Offset="0.488" />
        <GradientStop Color="#FFFFD02E" Offset="0.502" />
        <GradientStop Color="#FFFFD932" Offset="0.834" />
        <GradientStop Color="#FFFFF48B" Offset="1" />
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="MouseOverBorderBrush" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#FFEEE8CF" Offset="0" />
        <GradientStop Color="#FFC4AF8C" Offset="0.536" />
        <GradientStop Color="#FFDCD1BF" Offset="1" />
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="MouseOverHighlightBrush" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#FFFFFFFB" Offset="0" />
        <GradientStop Color="#FFFEF3B5" Offset="1" />
    </LinearGradientBrush>

    <!-- VERTEX CONTROL -->
    <Style TargetType="{x:Type controls:VertexControl}">
        <!-- Set background color through attached property -->
        <Setter Property="Background" Value="{StaticResource NormalBrush}"/>
        <Setter Property="Padding" Value="10,5,10,5"/>
        <Setter Property="BorderBrush" Value="{StaticResource NormalBorderBrush}"/>
        <Setter Property="BorderThickness" Value="3"/>

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type controls:VertexControl}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HoverOn">
                            <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundOver" Storyboard.TargetProperty="Opacity" To="1" />
                            <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundOver_Highlight" Storyboard.TargetProperty="Opacity" To="0.65" />
                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="BackgroundOver" Storyboard.TargetProperty="Opacity" To="0" />
                            <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="BackgroundOver_Highlight" Storyboard.TargetProperty="Opacity" To="0" />
                        </Storyboard>
                    </ControlTemplate.Resources>

                    <Grid>
                        <Border x:Name="BackgroundNorm" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="5" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"/>
                        <Border x:Name="BackgroundNorm_highlight" Margin="1" BorderBrush="{DynamicResource NormalHighlightBrush}" BorderThickness="1,0,1,1" CornerRadius="5" Opacity="0.65" />
                        <Border x:Name="BackgroundOver" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="5" Opacity="0" Background="{DynamicResource MouseOverBrush}" BorderBrush="{DynamicResource MouseOverBorderBrush}"/>
                        <Border x:Name="BackgroundOver_Highlight" Margin="1" BorderThickness="1,0,1,1" CornerRadius="5" Opacity="0" BorderBrush="{DynamicResource MouseOverHighlightBrush}"/>

                        <Grid >
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Image Source="{Binding ImageId, Converter={StaticResource ValueToImage}}" Margin="3"  Width="60" Stretch="UniformToFill" Grid.RowSpan="2"/>
                            <Label Content="{Binding Name}" VerticalAlignment="Center" FontWeight="Bold" Foreground="Black" Grid.Column="1" Grid.Row="0" Margin="3" MinWidth="120"/>
                            <TextBlock Text="{Binding Profession}" TextAlignment="Center" FontStyle="Italic" FontSize="14" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White" Grid.Column="1" Grid.Row="1" Margin="3"/>
                        </Grid>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}" x:Name="HoverOff_BeginStoryboard" />
                            </Trigger.ExitActions>
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}" />
                            </Trigger.EnterActions>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>

        </Setter>

        <Setter Property="ToolTip">
            <Setter.Value>
                <Border BorderBrush="Black" BorderThickness="2" CornerRadius="8" Background="{StaticResource NormalBrush}" UseLayoutRounding="True">
                    <StackPanel Orientation="Vertical">
                        <TextBlock Text="Additional person info:" Margin="4" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="14" FontWeight="Bold"/>
                        <StackPanel Orientation="Horizontal" Margin="3">
                            <TextBlock MinWidth="70" Text="Name: " VerticalAlignment="Center"/>
                            <TextBlock FontWeight="Bold" Text="{Binding Name}" Margin="3" VerticalAlignment="Center"/>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal" Margin="3">
                            <TextBlock MinWidth="70" Text="Occupation: " VerticalAlignment="Center"/>
                            <TextBlock FontWeight="Bold" Text="{Binding Profession}" Margin="3" VerticalAlignment="Center"/>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal" Margin="3">
                            <TextBlock MinWidth="70" Text="Age: " VerticalAlignment="Center"/>
                            <TextBlock FontWeight="Bold" Text="{Binding Age}" Margin="3" VerticalAlignment="Center"/>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal" Margin="3">
                            <TextBlock MinWidth="70" Text="Gender: " VerticalAlignment="Center"/>
                            <TextBlock FontWeight="Bold" Text="{Binding Gender}" Margin="3" VerticalAlignment="Center"/>
                        </StackPanel>
                    </StackPanel>
                </Border>
            </Setter.Value>
        </Setter>

        <!-- VERTEX DRAGGING CONTROL -->
        <Setter Property="controls:DragBehaviour.IsDragEnabled"
                Value="False" />
        <Setter Property="controls:DragBehaviour.UpdateEdgesOnMove"
                Value="True" />


        <Style.Triggers>
            <Trigger Property="controls:HighlightBehaviour.Highlighted" Value="True">
                <Setter Property="BorderBrush" Value="Gold"/>
                <Setter Property="BorderThickness" Value="7"/>
            </Trigger>
        </Style.Triggers>

    </Style>

    <controls:VisibilityToBoolConverter Inverted="True" Not="True"  x:Key="BooleanToVisibility"/>
    <controls:GeometryToPathGeometryConverter x:Key="GeometryToPathGeometry"/>

    <!-- EDGE CONTROL -->
    <Style TargetType="{x:Type controls:EdgeControl}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type controls:EdgeControl}">
                    <Grid>
                        <Path Stroke="{TemplateBinding Foreground}"
                          StrokeThickness="2" MinWidth="1" MinHeight="1"
                          ToolTip="{TemplateBinding ToolTip}"
                          x:Name="PART_edgePath"/>
                        <controls:DefaultEdgePointer NeedRotation="true" x:Name="PART_EdgePointerForTarget" >
                            <Path Data="M0,0.5 L1,1 1,0" Fill="{TemplateBinding Foreground}" Stretch="Uniform" Width="15" Height="15"/>
                        </controls:DefaultEdgePointer>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>

        <Setter Property="MinWidth"
                Value="1" />
        <Setter Property="MinHeight"
                Value="1" />
        <Setter Property="Background"
                Value="Red" />
        <Setter Property="Foreground"
                Value="Black" />
        <Setter Property="Opacity"
                Value="1" />

        <Setter Property="ToolTip">
            <Setter.Value>
                <Border BorderBrush="Black" BorderThickness="2" CornerRadius="2" Background="{StaticResource NormalBrush}" UseLayoutRounding="True">
                    <StackPanel Orientation="Vertical" Margin="2">
                        <TextBlock FontWeight="Bold" Text="Solid link: " Margin="3"/>
                        <TextBlock FontWeight="Bold" Foreground="LightGreen" Text="{Binding ToolTipText}" Margin="3"/>
                    </StackPanel>
                </Border>
            </Setter.Value>
        </Setter>


        <Style.Triggers>
            <Trigger Property="controls:HighlightBehaviour.Highlighted" Value="True">
                <Setter Property="Foreground" Value="Gold"/>
                <Setter Property="StrokeThickness" Value="5"/>
            </Trigger>
        </Style.Triggers>
    </Style>

</ResourceDictionary>